﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MainSite.Master" AutoEventWireup="true" CodeBehind="PersonalKPIs_new.aspx.cs" Inherits="BSCMFF.Web.Pages.BSC_Setup.PersonalKPIs_new" culture="auto" meta:resourcekey="PageResource1" uiculture="auto" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" 
        meta:resourcekey="RadAjaxLoadingPanel1Resource1" >
</telerik:RadAjaxLoadingPanel>

<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" 
        LoadingPanelID="RadAjaxLoadingPanel1" HorizontalAlign="NotSet" 
        meta:resourcekey="RadAjaxPanel1Resource1">
<asp:Label ID="LabelEmployees" runat="server" Text="Your inferior Employees" 
        meta:resourcekey="LabelEmployeesResource1"></asp:Label>
    <telerik:RadGrid ID="RadGridUserPKPIsWeight" runat="server" 
        AllowFilteringByColumn="True" AllowPaging="True" CellSpacing="0" 
         GridLines="None" 
        AllowSorting="True" AutoGenerateColumns="False" 
        onneeddatasource="RadGridUserPKPIsWeight_NeedDataSource" 
        meta:resourcekey="RadGridUserPKPIsWeightResource1">
        <MasterTableView DataKeyNames="ID" CommandItemDisplay="Top"
            >
            <CommandItemSettings ExportToPdfText="Export to PDF" 
                ShowAddNewRecordButton="False" />
            <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
            </RowIndicatorColumn>
            <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
            </ExpandCollapseColumn>
            <Columns>
                <telerik:GridBoundColumn DataField="ID" DataType="System.Int32" Visible="False"
                    FilterControlAltText="Filter ID column" HeaderText="ID" ReadOnly="True" 
                    SortExpression="ID" UniqueName="ID" 
                    meta:resourcekey="GridBoundColumnResource1">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Firstname" 
                    FilterControlAltText="Filter Firstname column" HeaderText="Firstname" 
                    SortExpression="Firstname" UniqueName="Firstname" 
                    meta:resourcekey="GridBoundColumnResource2">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Lastname" 
                    FilterControlAltText="Filter Lastname column" HeaderText="Lastname" 
                    SortExpression="Lastname" UniqueName="Lastname" 
                    meta:resourcekey="GridBoundColumnResource3">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Email" 
                    FilterControlAltText="Filter Email column" HeaderText="Email" 
                    SortExpression="Email" UniqueName="Email" 
                    meta:resourcekey="GridBoundColumnResource4">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="EmployeeID" 
                    FilterControlAltText="Filter EmployeeID column" HeaderText="EmployeeID" 
                    SortExpression="EmployeeID" UniqueName="EmployeeID" 
                    meta:resourcekey="GridBoundColumnResource5">
                </telerik:GridBoundColumn>
                
                <telerik:GridBoundColumn DataField="Job_Position" 
                    FilterControlAltText="Filter Job_Position column" HeaderText="Job_Position" 
                    SortExpression="Job_Position" UniqueName="Job_Position" 
                    meta:resourcekey="GridBoundColumnResource6">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="TotalPKPIsWeight" DataType="System.Int32"
                    FilterControlAltText="Filter TotalPKPIsWeight column" HeaderText="TotalPKPIsWeight" 
                    SortExpression="TotalPKPIsWeight" UniqueName="TotalPKPIsWeight" 
                    meta:resourcekey="GridBoundColumnResource7">
                </telerik:GridBoundColumn>
            </Columns>
            <EditFormSettings>
                <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                </EditColumn>
            </EditFormSettings>
        </MasterTableView>
        <FilterMenu EnableImageSprites="False">
        </FilterMenu>
        <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
        </HeaderContextMenu>
    </telerik:RadGrid>
</telerik:RadAjaxPanel>    
<br />
<telerik:RadAjaxPanel ID="RadAjaxPanel2" runat="server" 
        LoadingPanelID="RadAjaxLoadingPanel1" HorizontalAlign="NotSet" 
        meta:resourcekey="RadAjaxPanel2Resource1">
<asp:Label ID="LabelEmployeePKPIs" runat="server" 
        Text="Manage Employee's Personal KPIs" 
        meta:resourcekey="LabelEmployeePKPIsResource1" ></asp:Label>
<br />
<telerik:RadComboBox ID="RadComboBoxEmployee" runat="server" Height="200px" 
        Width="200px" ViewStateMode="Enabled"
        DropDownWidth="298px" EmptyMessage="Choose an Employee" 
        AllowCustomText="True" Filter="Contains"
                HighlightTemplatedItems="True" 
                DataTextField="Fullname" DataValueField="ID" 
                AutoPostBack="True" meta:resourcekey="RadComboBoxEmployeeResource1" 
                        
        >
        <HeaderTemplate>
            <table style="width: 275px" cellspacing="0" cellpadding="0">
                <tr>
                    <td style="width: 55px;">
                        <asp:Label ID="LabelPhoto" runat="server" Text="Photo" 
                            meta:resourcekey="LabelPhotoResource1" ></asp:Label>
                    </td>
                    <td style="width: 180px;">
                        <asp:Label ID="LabelEmployeeName" runat="server" Text="Fullname" 
                            meta:resourcekey="LabelEmployeeNameResource1" ></asp:Label>
                    </td>
                    <td style="width: 60px;">
                        <asp:Label ID="LabelJobPosition" runat="server" Text="Job Position" 
                            meta:resourcekey="LabelJobPositionResource1" ></asp:Label>
                    </td>
                </tr>
            </table>
        </HeaderTemplate>
        <ItemTemplate>
            <table style="width: 300px" cellspacing="0" cellpadding="2">
                <tr>
                    <td style="width: 55px;">
                        <telerik:RadBinaryImage ID="RadBinaryImage1" runat="server" 
                            DataValue='<%# Eval("Photo") %>' ImageUrl="~/Images/silhouette/silhouette-stewie.jpg"
                        Width="50px" Height="50px" AutoAdjustImageControlSize="False" 
                            meta:resourcekey="RadBinaryImage1Resource1" />
                    </td>
                    <td style="width: 180px;">
                        <%--<%# DataBinder.Eval(Container, "User.Login")%>--%>
                    </td>
            
                    <td style="width: 60px;">
                        <%# Eval("Job_Position")%>
                    </td>
                </tr>
            </table>
        </ItemTemplate>
        </telerik:RadComboBox>
        <asp:CheckBox ID="CheckBoxNotOkOnly" runat="server" AutoPostBack="True" Visible="False"
        OnCheckedChanged="CheckBoxNotOkOnly_Changed" 
        Text="Show Only Employees, who have not 100% of weights." 
        meta:resourcekey="CheckBoxNotOkOnlyResource1"/>
    <asp:Panel ID="PanelEmployeePKPIs" runat="server" Visible="False" 
        meta:resourcekey="PanelEmployeePKPIsResource1">
    <telerik:RadGrid ID="RadGridPersonalKPIs" runat="server" 
    CellSpacing="0"  
    GridLines="None" AutoGenerateColumns="False" DataSourceID="EntityDataSourcePKPIs" 
    OnInsertCommand="RadGridPersonalKPIs_InsertCommand"
    OnUpdateCommand="RadGridPersonalKPIs_UpdateCommand"
    OnDeleteCommand="RadGridPersonalKPIs_DeleteCommand"
    OnItemDataBound="RadGridPersonalKPIs_ItemDataBound" 
            ondatabound="RadGridPersonalKPIs_DataBound" 
            meta:resourcekey="RadGridPersonalKPIsResource1">
        
    <MasterTableView DataKeyNames="Personal_KPI_ID" 
            DataSourceID="EntityDataSourcePKPIs" ShowFooter="True"
            CommandItemDisplay="Top">
    
    <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>

    <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
    </RowIndicatorColumn>

    <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
    </ExpandCollapseColumn>

        <Columns>
            <telerik:GridBoundColumn DataField="KPI.Name" 
                FilterControlAltText="Filter KPI.Name column" HeaderText="KPI" 
                meta:resourcekey="GridBoundColumnResource8" ReadOnly="True" 
                SortExpression="KPI.Name" UniqueName="KPI.Name">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Personal_KPI_ID" DataType="System.Int32" 
                FilterControlAltText="Filter Personal_KPI_ID column" 
                HeaderText="Personal_KPI_ID" meta:resourcekey="GridBoundColumnResource9" 
                ReadOnly="True" SortExpression="Personal_KPI_ID" UniqueName="Personal_KPI_ID" 
                Visible="False">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Name" 
                FilterControlAltText="Filter Name column" HeaderText="Name" 
                meta:resourcekey="GridBoundColumnResource10" SortExpression="Name" 
                UniqueName="Name">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Description" 
                FilterControlAltText="Filter Description column" HeaderText="Description" 
                meta:resourcekey="GridBoundColumnResource11" SortExpression="Description" 
                UniqueName="Description" Visible="False">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="User_FK" DataType="System.Int32" 
                FilterControlAltText="Filter User_FK column" HeaderText="User_FK" 
                meta:resourcekey="GridBoundColumnResource12" SortExpression="User_FK" 
                UniqueName="User_FK" Visible="False">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="KPI_FK" DataType="System.Int32" 
                FilterControlAltText="Filter KPI_FK column" HeaderText="KPI_FK" 
                meta:resourcekey="GridBoundColumnResource13" SortExpression="KPI_FK" 
                UniqueName="KPI_FK" Visible="False">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Measure" 
                FilterControlAltText="Filter Measure column" HeaderText="Measure" 
                meta:resourcekey="GridBoundColumnResource14" SortExpression="Measure" 
                UniqueName="Measure">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="MeasureType" 
                FilterControlAltText="Filter MeasureType column" HeaderText="MeasureType" 
                meta:resourcekey="GridBoundColumnResource15" SortExpression="MeasureType" 
                UniqueName="MeasureType" Visible="False">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="CurrentValue" DataType="System.Int32" 
                FilterControlAltText="Filter CurrentValue column" HeaderText="CurrentValue" 
                meta:resourcekey="GridBoundColumnResource16" SortExpression="CurrentValue" 
                UniqueName="CurrentValue">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="StartValue" DataType="System.Int32" 
                FilterControlAltText="Filter StartValue column" HeaderText="StartValue" 
                meta:resourcekey="GridBoundColumnResource17" SortExpression="StartValue" 
                UniqueName="StartValue">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="TargetValue" DataType="System.Int32" 
                FilterControlAltText="Filter TargetValue column" HeaderText="TargetValue" 
                meta:resourcekey="GridBoundColumnResource18" SortExpression="TargetValue" 
                UniqueName="TargetValue">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Percentage" 
                FilterControlAltText="Filter Percentage column" HeaderText="Percentage" 
                meta:resourcekey="GridBoundColumnResource19" ReadOnly="True" 
                SortExpression="Percentage" UniqueName="Percentage">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Weight" DataType="System.Int32" 
                FilterControlAltText="Filter Weight column" HeaderText="Weight" 
                meta:resourcekey="GridBoundColumnResource20" SortExpression="Weight" 
                UniqueName="Weight">
            </telerik:GridBoundColumn>
            <telerik:GridButtonColumn CommandName="Edit" 
                FilterControlAltText="Filter column column" 
                meta:resourcekey="GridButtonColumnResource1" Text="Edit" UniqueName="column">
            </telerik:GridButtonColumn>
            <telerik:GridButtonColumn CommandName="Delete" 
                FilterControlAltText="Filter column1 column" 
                meta:resourcekey="GridButtonColumnResource2" Text="Delete" UniqueName="column1">
            </telerik:GridButtonColumn>
        </Columns>

    <EditFormSettings EditFormType="WebUserControl" UserControlName="~/UserControls/Details/PKPIDetails.ascx">
    <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
    </EditFormSettings>
    </MasterTableView>

    <FilterMenu EnableImageSprites="False"></FilterMenu>

    <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu>
        
</telerik:RadGrid>
<asp:HiddenField ID="HiddenFieldTotalWeights" runat="server" Value="0"/>
       <div style="float:right"> <telerik:RadButton ID="RadButtonAssignEvenWeights" runat="server" 
            Text="Assign Weights Evenly"  
            onclick="RadButtonAssignEvenWeights_Click" 
               meta:resourcekey="RadButtonAssignEvenWeightsResource1">
        </telerik:RadButton>
        </div>
</asp:Panel>
</telerik:RadAjaxPanel>
    <asp:EntityDataSource ID="EntityDataSourceUsersPKPIsWeights" runat="server" 
        ConnectionString="name=BSCEntities" DefaultContainerName="BSCEntities" 
        EnableFlattening="False" EntitySetName="Users" Include="Personal_KPI" 
        EntityTypeFilter="" Select="" >
    </asp:EntityDataSource>

    <asp:EntityDataSource ID="EntityDataSourcePKPIs" runat="server" 
        ConnectionString="name=BSCEntities" DefaultContainerName="BSCEntities" 
        EnableFlattening="False" EntitySetName="Personal_KPI" Include="KPI" 
        Where="it.User_FK = @user_FK" EntityTypeFilter="" Select="">
        <WhereParameters>
            <asp:ControlParameter ControlID="RadComboBoxEmployee" DbType="Int32" 
                DefaultValue="0" Name="user_FK" PropertyName="SelectedValue" />
        </WhereParameters>
    </asp:EntityDataSource>
    <asp:EntityDataSource ID="EntityDataSourceKPIs" runat="server" 
        ConnectionString="name=BSCEntities" DefaultContainerName="BSCEntities" 
        EnableFlattening="False" EntitySetName="KPIs" 
        Select="it.[KPI_ID], it.[Name]" EntityTypeFilter="">
    </asp:EntityDataSource>

</asp:Content>
